<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<%@taglib prefix="mvc" uri="http://www.springframework.org/tags/form" %>
<%@taglib prefix="fmt" uri="http://www.springframework.org/tags" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>客户合同详情</title>
    <link rel="stylesheet" type="text/css" href="../../lib/pagination/style/pagination.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/base.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/news/center.css"/>
    <link rel="stylesheet" href="/lib/laydate/need/laydate.css">


    <script type="text/javascript" src="../../js/jquery/jquery-1.9.1.js"></script>
    <script src="../../lib/layer/layer.js?20201106"></script>
    <script src="../../js/news/page.js"></script>
    <script src="/lib/laydate/laydate.js"></script>
    <script src="../../js/base/base.js" type="text/javascript" charset="utf-8"></script>
    <script src="../../lib/pagination/js/jquery.pagination.min.js" type="text/javascript" charset="utf-8"></script>

    <style>
        * {font-family: "Microsoft Yahei" !important;}
        b{
            color: red;
        }
        .head_title{
            margin-top: 10px;
            height: 40px;
            position: relative;
        }
        .head_title .title{
            margin-left: 22px;
        }
        .head_title span{
            float: none;
            /*margin-top: 9px;*/
            font-size: 22px;
            color: #333;
            display: inline-block;
            margin-left: 10px;
            vertical-align: middle;
            margin-top: -6px;
        }
        .saveBtn{
            display: block;
            float: left;
            background: url(../img/confirm.png) no-repeat;
            border: none;
            width: 70px;
            height: 29px;
            line-height: 29px;
            margin-left: 10px;
            cursor: pointer;
        }
        .resetBtn {
            display: block;
            float: left;
            background: url(../img/news/new_filling.png) no-repeat;
            border: none;
            width: 70px;
            height: 29px;
            line-height: 29px;
            margin-left: 10px;
            cursor: pointer;
        }
        .div_Btn{
            margin: 1% 43%;
        }
        select{
            width: 250px;
            height: 30px;
        }
        .newTbale tr td {
            border-right: #ccc 1px solid;
            padding: 5px 30px;
        }
        input[type="text"]{
            width: 250px;
            height: 30px;
        }
        .newTbale {
            width: 85%;
            margin: 0px auto;
        }
        table {
            border-collapse: collapse;
            border-spacing: 0;
        }
    </style>
    <link rel="stylesheet" type="text/css" href="/css/commonTheme/${sessionScope.InterfaceModel}/commonTheme.css"/>
</head>
<body>
<!--head开始-->
<div class="head_title">
    <div class="title">
        <img src="/img/commonTheme/${sessionScope.InterfaceModel}/flow_run_title.png"><span style="">客户合同详情</span>
    </div>
</div>
<div id="pagediv">
    <form id="ajaxforms" action="/addCrmContract/addCrmContract">
        <table class="newTbale">
            <tr>
                <td>合同名称:</td>
                <td><input type="text" name="contractName" disabled="true"/></td>
                <td>所属客户</td>
                <td>
                    <select name="customerName" disabled="true" style="width: 252px" >

                    </select>
                </td>
            </tr>
            <tr>
                <td>合同类型:</td>
                <td>
                    <select name="type" disabled="true" style="width: 252px" >
                        <option value="">选择付款方式</option>
                        <option value="0">产品销售</option>
                        <option value="1">业务销售</option>
                        <option value="2">售后服务</option>
                    </select>
                </td>
                <td>合同状态:</td>
                <td>
                    <select name="status" disabled="true" style="width: 252px" >
                        <option value="0">执行中</option>
                        <option value="1">结束</option>
                        <option value="2">意外终止</option>
                    </select>
                </td>
            </tr>
            <tr>
                <td>总金额:</td>
                <td><input type="text" disabled="true" name="total" /></td>
                <td>总金额大写:</td>
                <td><input type="text" disabled="true" name="totalCaps" /></td>
            </tr>
            <tr>
                <td>付款方式:</td>
                <td>
                    <select name="payWay" disabled="true">
                        <option value="">选择付款方式</option>
                    </select>
                </td>
                <td>已收款:</td>
                <td><input type="text" disabled="true" name="receivedMoney"/></td>
            </tr>
            <tr>
                <td>开始时间:</td>
                <td>
                    <input type="text" disabled="true" name="startTime"   placeholder="请输入时间" id="startTime"  onclick="laydate({istime: true, format: 'YYYY-MM-DD hh:mm:ss'})"/>
                </td>
                <td>结束时间:</td>
                <td>
                    <input type="text" disabled="true" name="endTime"   placeholder="请输入时间" id="endTime"  onclick="laydate({istime: true, format: 'YYYY-MM-DD hh:mm:ss'})"/>
                </td>
            </tr>
            <tr>
                <td>合同有效期:</td>
                <td><input type="text" disabled="true" name="validTime" onclick="laydate({istime: true, format: 'YYYY-MM-DD hh:mm:ss'})"/></td>
                <td>到期事务提醒:</td>
                <td disabled="true">
                    <input type="radio" disabled="true" name="remindExpire" checked="checked"   value="0"/>否
                    <input type="radio" disabled="true" name="remindExpire"   value="1"/>是
                </td>
            </tr>
            <tr>
                <td>到期短信提醒:</td>
                <td disabled="true">
                    <input type="radio" disabled="true" name="remindExpireSms" checked="checked"   value="0"/>否
                    <input type="radio" disabled="true" name="remindExpireSms"   value="1"/>是
                </td>
                <td>收款时间:</td>
                <td><input type="text" disabled="true" name="recieveTime" onclick="laydate({istime: true, format: 'YYYY-MM-DD hh:mm:ss'})"/></td>
            </tr>
            <tr>
                <td>交付时间:</td>
                <td><input type="text" disabled="true" name="deliverTime" onclick="laydate({istime: true, format: 'YYYY-MM-DD hh:mm:ss'})"/></td>
                <td>收款事务提醒:</td>
                <td disabled="true">
                    <input type="radio" disabled="true" name="remindRecieve" checked="checked"   value="0"/>否
                    <input type="radio" disabled="true" name="remindRecieve"   value="1"/>是
                </td>
            </tr>
            <tr>
                <td>收款短信提醒:</td>
                <td disabled="true">
                    <input type="radio" disabled="true" name="remindRecieveSms" checked="checked"   value="0"/>否
                    <input type="radio" disabled="true" name="remindRecieveSms"   value="1"/>是
                </td>
                <td>交付事务提醒:</td>
                <td disabled="true">
                    <input type="radio" disabled="true" name="remindDeliver" checked="checked"   value="0"/>否
                    <input type="radio" disabled="true" name="remindDeliver"   value="1"/>是
                </td>
            </tr>
            <tr>
                <td>交付短信提醒:</td>
                <td disabled="true">
                    <input type="radio" disabled="true" name="remindDeliverSms" checked="checked"   value="0"/>否
                    <input type="radio" disabled="true" name="remindDeliverSms"   value="1"/>是
                </td>
                <td>合同内容:</td>
                <td><input type="text" disabled="true" name="content"/></td>
            </tr>
            <tr>
                <td>甲方签约时间:</td>
                <td>
                    <input type="text" disabled="true" name="fistPartySignTime" readonly="readonly"  placeholder="请输入时间" id="fistPartySignTime"  onclick="laydate({istime: true, format: 'YYYY-MM-DD hh:mm:ss'})"/>
                </td>
                <td>甲方:</td>
                <td><input type="text" disabled="true" name="fistParty"/></td>
            </tr>
            <tr>
                <td>乙方签约时间:</td>
                <td>
                    <input type="text" disabled="true" name="secondPartySignTime" readonly="readonly"  placeholder="请输入时间" id="secondPartySignTime"  onclick="laydate({istime: true, format: 'YYYY-MM-DD hh:mm:ss'})"/>

                </td>
                <td>乙方:</td>
                <td><input type="text" disabled="true" name="secondParty"/></td>
            </tr>
            <tr>
                <td>项目:</td>
                <td><input type="text" disabled="true" name="item"/></td>
                <td>审批状态:</td>
                <td>
                    <select disabled="true" name="approvalStatus" style="width: 252px" >
                        <option value="0">待审批</option>
                        <option value="1">已通过</option>
                        <option value="2">已驳回</option>
                    </select>
                </td>
            </tr>
            <tr>
                <td>审批人:</td>
                <td><input type="text" disabled="true" name="approvalUser"/></td>
                <td>审批时间:</td>
                <td><input type="text" disabled="true" name="approvalTime"  onclick="laydate({istime: true, format: 'YYYY-MM-DD hh:mm:ss'})"/></td>
            </tr>
            <tr>
                <td>审批意见:</td>
                <td><input type="text" disabled="true" name="approvalAdvice"/></td>
                <td>备注:</td>
                <td><input type="text" disabled="true" name="remark"/></td>
            </tr>
        </table>
    </form>
</div>
<div class="div_Btn">

    <div class="resetBtn" onclick="javascript:window.location.href='/crmContract/index';">
        <span  style="margin-left: 32px;" >返回</span>
    </div>
</div>
</body>
<script>
    var getRequestObj=$.GetRequest();
    function GetDropDownBox(fn) {
        $.ajax({
            url: "/crmContract/selectByConditionCust",
            type: 'get',
            dataType: "JSON",
            async: false,
            success: function (data) {
                var str = '<option value="">请选择客户</option>';
                for (var i = 0; i < data.obj.length; i++) {
                    str += '<option value="' + data.obj[i].customerId + '">' + data.obj[i].customerName + '</option>'
                }
                $('[name="customerName"]').html(str);
            }
        })
        $.ajax({
            url: "/crmContract/selectByContract",
            type: 'get',
            dataType: "JSON",
            async: false,
            success: function (data) {
                var str = '<option value="">请选择合同类型</option>';
                for (var i = 0; i < data.obj.length; i++) {
                    str += '<option value="' + data.obj[i].codeNo + '">' + data.obj[i].codeName + '</option>'
                }
                $('[name="type"]').html(str);
            }
        })

        $.ajax({
            url: "/crmContract/selectByPayment",
            type: 'get',
            dataType: "JSON",
            async: false,
            success: function (data) {
                var str = '<option value="">请选择付款方式</option>';
                for (var i = 0; i < data.obj.length; i++) {
                    str += '<option value="' + data.obj[i].codeNo + '">' + data.obj[i].codeName + '</option>'
                }
                $('[name="payWay"]').html(str);
            }
        })
    }
    function  ajaxforms() {
        $.ajax({
            url: '/crmContract/updateCrmContract  ',
            type: 'post',
            dataType: 'json',
            data: $('#ajaxforms').serialize()+'&contractId='+getRequestObj.contractId,
            success: function (data) {
                if(data.flag){
                    layer.msg('修改成功！',{icon:1},function () {
                        window.close();
                        window.location.href='/crmContract/index'
                    });
                }else{
                    alert("修改失败！");
                }
            },
            error: function (data) {
                alert("修改失败！");
            }
        })
    }
    //数据回显
    $(function () {
        GetDropDownBox(function(){
            $('[name="monetaryUnit"]').val(getRequestObj.codeNo);
            $('[name="payWay"]').val(getRequestObj.codeNo);
            $('[name="customerName"]').val(getRequestObj.customerId);
        });
        $.ajax({
            url:'/crmContract/selectCrmContractById',
            data:{
                contractId:getRequestObj.contractId
            },
            async:false,
            type: 'get',
            dataType: 'json',
            success:function (json) {
                if (json.flag) {
                    $('[name="contractName"]').val(json.data.contractName);
                    $('[name="customerName"]').val(json.data.customerId);
                    $('[name="type"]').val(json.data.type);
                    $('[name="payWay"]').val(json.data.payWay);
                    $('[name="status"]').val(json.data.status);
                    $('[name="total"]').val(json.data.total);
                    $('[name="totalCaps"]').val(json.data.totalCaps);
                    $('[name="receivedMoney"]').val(json.data.receivedMoney);
                    $('[name="startTime"]').val(json.data.startTime);
                    $('[name="endTime"]').val(json.data.endTime);
                    $('[name="validTime"]').val(json.data.validTime);
                    $('[name="remindExpire"][value="'+json.data.remindExpire+'"]').prop('checked','checked')
                    $('[name="remindExpireSms"][value="'+json.data.remindExpireSms+'"]').prop('checked','checked')
                    $('[name="recieveTime"]').val(json.data.recieveTime)
                    $('[name="deliverTime"]').val(json.data.deliverTime)
                    $('[name="remindRecieve"][value="'+json.data.remindRecieve+'"]').prop('checked','checked')
                    $('[name="remindRecieveSms"][value="'+json.data.remindRecieveSms+'"]').prop('checked','checked')
                    $('[name="remindDeliver"][value="'+json.data.remindDeliver+'"]').prop('checked','checked')
                    $('[name="remindDeliverSms"][value="'+json.data.remindDeliverSms+'"]').prop('checked','checked')
                    $('[name="content"]').val(json.data.content)
                    $('[name="fistPartySignTime"]').val(json.data.fistPartySignTime)
                    $('[name="fistParty"]').val(json.data.fistParty)
                    $('[name="secondPartySignTime"]').val(json.data.secondPartySignTime)
                    $('[name="secondParty"]').val(json.data.secondParty)
                    $('[name="item"]').val(json.data.item)
                    $('[name="approvalStatus"]').val(json.data.approvalStatus)
                    $('[name="approvalUser"]').val(json.data.approvalUser)
                    $('[name="approvalTime"]').val(json.data.approvalTime)
                    $('[name="approvalAdvice"]').val(json.data.approvalAdvice)
                    $('[name="remark"]').val(json.data.remark)

                } else {
                    $.layerMsg({content: '网络错误！', icon: 2});
                }
            }
        })
    })
</script>
</html>
